<template>
    <div>
        <to-pou :params="params" @walletOpenHandel="walletOpenHandel" :user="user" ></to-pou>
        <top-ji :share="share" :user="user" :countdown="countdown"></top-ji>
        <div style="margin-top: 10px;padding: 0 15px; height: 450px; border-radius: 10px; position: relative;">
            <iframe  :src="gameUrl" style="border-radius: 10px;border: medium none; top: 0;left: 3%; width: 93%; position: absolute;height: 450px;"></iframe>
        </div>

        <div style="padding: 0 15px; margin-top: 10px;">
            <div @click="openHandel" :style="user.hp==0?'background: #848484;':'background: #F6CB23;'" style="color: #000; font-weight: bold;text-align: center; border-radius: 10px;font-size: 17px; height: 54px; line-height: 54px;" class="center">
                {{ user.hp == 0 ? 'No lives left today' : 'Start Game & Earn Points' }}
            </div>
        </div>
        <!-- <div style="padding-bottom: 50px;"></div> -->
        <div v-if="drawer" style="bottom: 0;width: 100%; background: rgb(27, 32, 37);border-top-right-radius: 20px;border-top-left-radius: 20px;position: fixed;z-index: 1000;">
            <div style="padding: 20px;">
                <div v-if="!tys">
                    <div style="display: flex;justify-content: space-between;line-height: 40px; align-items: center;">
                        <div style="font-size: 26px; color:#fff" >{{ title }}</div>
                        <el-icon color="#fff" @click="drawer = false"><CloseBold /></el-icon>
                    </div>
                    <div  style="color: #fff;font-size: 15px;line-height: 25px; width: 93%; margin-top: 20px; margin-bottom: 10px;">{{ con }}</div>
                    <div class="sbumit_bnt" style="line-height: 50px;height: 50px; border-radius: 10px;" size="default" type="default" hover-class="is-hover" @click="tys = true">{{ btn }}</div>

                </div>

                <div v-else>
                    <div style="display: flex;justify-content: space-between;line-height: 30px; align-items: center;">
                        <div style="font-size: 26px; color:#fff" >Invite Friends</div>
                        <el-icon color="#fff" @click="drawer = false"><CloseBold /></el-icon>
                    </div>
                    <div style="font-size: 13px;color: #fff;">Share and get extra bonus points</div>
                    <div style="position: relative;margin-top: 30px;">
                        <div style="background-color:rgba(255, 255, 255, 0.16);height: 50px;border-radius: 10px; padding-left: 10px; color: #fff;align-items: center; display: flex;justify-content: space-between;">
                            <div style="overflow: hidden;font-size: 12px;width: 85%;text-overflow:ellipsis;white-space: nowrap;-o-text-overflow:ellipsis;">{{ postContent }}</div>
                            <img @click="copy" style="position: absolute; right: 10px; top: 12px; width: 25px;height: 25px;" src="../static/img/copy-01.png" />

                        </div>
                    </div>
                    <div class="sbumit_bnt" style="line-height: 50px;height: 50px; border-radius: 10px; font-size: 17px;" size="default" type="default" hover-class="is-hover" @click="send">Send Link</div>

                </div>

            </div>
        </div>
  
    </div>
</template>

<script>
import ToPou from './personInforma.vue'
import TopJi from './TopJi.vue';
import { ElMessage } from 'element-plus'
export default {
    components: {
        ToPou,
        TopJi
    },
    props: {
        user: {
            type: [Object, String],
            default: () => { }
        },
        gameUrl: {
            type: String,
            default:() => ''
        },
        countdown: {
            type: String,
            default:''
        },
        share: {
            type: [Object, String],
            default: () => { }
        },
        params: {
            type: [Object, String],
            default: () => { }
        },
    },
    data() {
        return {
            tys:false,
            drawer: false,
            title: 'Bonus Lives',
            con: 'You can get more lives by inviting friends. Each successful referral will five you one extralife.',
            btn: 'Invite Friends',
            postContent:''
        }
    },
    mounted(){
        this.postContent = 'https://t.me/JumpAndSay_bot/Jump?start=' + this.user.chatId
    },
    methods: {
        walletOpenHandel(data) {
            
            console.log('当前打开了',data)
            
        },
        send() {
             this.$copyText(this.postContent)
            ElMessage({ message: 'Copy success!', type: 'success' })
            this.drawer = false
            this.tys = false
        },
        copy() {
            this.$copyText(this.postContent)
            ElMessage({ message: 'Copy success!', type: 'success' })
        },
        handleClose() {
            this.drawer = false
        },
        signInHandel() {
            window.location.href = 'https://t.me/JumpAndSay_bot/Jump?start='+this.user.chatId
        },
         openHandel() {
            if (this.user.hp == 0) {
                this.drawer = true
            }
        },
        game() {
            this.$emit('game')
        }
    }
}
</script>

<style>

</style>

<style lang="scss" scoped>
.el-drawer__container {
  border-radius: 10px !important; /* 设置你想要的圆角值 */
}
.el-drawer__header {
  font-size: 26px; /* 设置你想要的字体大小 */
  color: #fff;
}

   input{
    border: none;
    height: 30px;
    line-height: 30px;
    color: #fff;
    background-color:rgba(255, 255, 255, 0.16);
    padding: 5px;
    border-radius: 5px;
    width: 96%;
}
 .sbumit_bnt{
    width: 100%;
    color: #000;
    background-color:  #f6cb23;
    border-color: #f6cb23;
    margin-bottom: 30px;
    margin-top: 30px;
    font-family: 'Inter';
    font-size: 17px;
    font-weight: 600;
    height: 40px;
    text-align: center;

}
</style>